<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
                <html lang="zh-CN">
                <head>
                    <meta charset="utf-8">
                    <meta http-equiv="X-UA-Compatible" content="IE=edge">
                    <meta name="viewport" content="width=device-width, initial-scale=1">
                    <title>CMS管理系统</title>

                    <link href="/Public/bootstrap/css/bootstrap.min.css" rel="stylesheet">
                    <link rel="stylesheet" href="/Public/css/common.css">
                    
                </head>
                <body>

                <nav class="navbar navbar-default navbar-fixed-top col-md-10">
                    <div class="container-fluid nav_bg">
                        <!-- Brand and toggle get grouped for better mobile display -->
                        <div class="navbar-header">
                            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                                <span class="sr-only">Toggle navigation</span>
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                            </button>
                            <a class="navbar-brand" href="<?php echo U('Index/index');?>">首页</a>
                        </div>

                        <!-- Collect the nav links, forms, and other content for toggling -->
                        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                            <ul class="nav navbar-nav">
                                <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
                                <li><a href="<?php echo U('Link/index');?>">友情链接管理</a></li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                                       aria-expanded="false">前端文件管理 <span class="caret"></span></a>
                                    <ul class="dropdown-menu">
                                        <li><a href="<?php echo U('File/index');?>">文件管理</a></li>
                                        <li role="separator" class="divider"></li>
                                        <li><a href="<?php echo U('Article/show');?>">Finder</a></li>
                                    </ul>
                                </li>

                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                                       aria-expanded="false">内容管理 <span class="caret"></span></a>
                                    <ul class="dropdown-menu">
                                        <li><a href="<?php echo U('Article/index');?>">文章列表</a></li>
                                        <li role="separator" class="divider"></li>
                                        <li><a href="<?php echo U('Category/index');?>">栏目管理</a></li>
                                    </ul>
                                </li>

                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                                       aria-expanded="false"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span> 系统设置 <span
                                            class="caret"></span></a>
                                    <ul class="dropdown-menu">
                                        <li><a href="<?php echo U('System/config');?>">站点信息</a></li>
                                        <li role="separator" class="divider"></li>
                                        <li><a href="<?php echo U('User/password_edit');?>">密码修改</a></li>
                                    </ul>
                                </li>

                            </ul>


                            <ul class="nav navbar-nav navbar-right">
                                <li><a href="<?php echo U('File/destroy_cache');?>">清除缓存</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false">尊敬的<?php echo ($user["username"]); ?> <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Action</a></li>
                        <li><a href="#">Another action</a></li>
                        <li><a href="#">Something else here</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="<?php echo U('User/logout');?>">安全退出</a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>

<div class="container-fluid">
    


            <div class="row">
                <div class="col-md-10">
                    <div class="panel panel-default">
                        <div class="panel-heading">栏目管理</div>

                        <div class="panel-body">
                            <form action="" method="post" id="form">
                                <table class="table table-hover">
                                    <thead >
                                    <tr>
                                        <th class="col-sm-1">排序</th>
                                        <th>名称</th>
                                        <th>栏目文章</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>


                                    <?php if(is_array($categories)): $i = 0; $__LIST__ = $categories;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$category): $mod = ($i % 2 );++$i;?><tr>
                                            <th scope="row" class="col-sm-1">
                                                <input type="hidden" name="ids[]" value="<?php echo ($category["id"]); ?>">
                                                <input type="text"  name="sort_order[]" value="<?php echo ($category["sort_order"]); ?>">
                                            </th>
                                            <td class="name" class="col-sm-1"><?php echo ($category["name"]); ?></td>


                                        </tr>


                                            <?php if(is_array($category['children'])): $i = 0; $__LIST__ = $category['children'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$c): $mod = ($i % 2 );++$i;?><tr>
                                                    <th scope="row" class="col-sm-1">
                                                        <input type="hidden" name="ids[]" value="<?php echo ($category["id"]); ?>">
                                                        <input type="text"  name="sort_order[]" value="<?php echo ($category["sort_order"]); ?>">
                                                    </th>
                                                    <th>
                                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo ($c["name"]); ?>
                                                    </th>
                                                    <td>
                                                        栏目文章
                                                    </td>
                                                    <td>
                                                        <a href="<?php echo U('add');?>">
                                                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                                                        </a>
                                                        <a href="<?php echo U('edit',array('id'=>$c['id']));?>">
                                                            <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                                                        </a>
                                                        <a href="<?php echo U('destroy',array('id'=>$c['id']));?>">
                                                            <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
                                                        </a>
                                                    </td>
                                                </tr><?php endforeach; endif; else: echo "" ;endif; endforeach; endif; else: echo "" ;endif; ?>


                                    </tbody>
                                </table>
                            </form>


                        </div>
                    </div>
                </div>

                <div class="col-md-2">
                    <div class="list-group">
                        <a href="<?php echo U('add');?>" class="list-group-item list-group-item-info create_link">
                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 新增 (add)
                        </a>



                        <a href="javascript: void 0;" class="list-group-item list-group-item-info sort_link">
                            <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 排序 (sort)
                        </a>
                    </div>
                </div>
            </div>


</div>
<script src="/Public/js/jquery.min.js"></script>

<script src="/Public/bootstrap/js/bootstrap.min.js"></script>


    <script>
        $(function () {
            $(".sort_link").click(function(){
                $("#form").attr("action","<?php echo U('sort_link');?>").submit();

            })
        })

    </script>


</body>
</html>